package com.baseweb.webadmin.core.model.mapper;

import com.baseweb.webadmin.core.model.pojo.ByArticle;
import com.baseweb.webadmin.core.model.pojo.ByArticleExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

public interface ByArticleMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_article
     *
     * @mbggenerated Mon Feb 06 01:03:58 CST 2017
     */
    int countByExample(ByArticleExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_article
     *
     * @mbggenerated Mon Feb 06 01:03:58 CST 2017
     */
    int deleteByExample(ByArticleExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_article
     *
     * @mbggenerated Mon Feb 06 01:03:58 CST 2017
     */
    @Delete({
        "delete from by_article",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_article
     *
     * @mbggenerated Mon Feb 06 01:03:58 CST 2017
     */
    @Insert({
        "insert into by_article (user_id, position_id, ",
        "article_type, img_url, ",
        "name, descn, status, ",
        "create_time, ",
        "update_time, ",
        "view_count)",
        "values (#{userId,jdbcType=INTEGER}, #{positionId,jdbcType=INTEGER}, ",
        "#{articleType,jdbcType=INTEGER}, #{imgUrl,jdbcType=VARCHAR}, ",
        "#{name,jdbcType=VARCHAR}, #{descn,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ",
        "#{createTime,jdbcType=TIMESTAMP,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2TimestampTypeHandler}, ",
        "#{updateTime,jdbcType=TIMESTAMP,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2TimestampTypeHandler}, ",
        "#{viewCount,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(ByArticle record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_article
     *
     * @mbggenerated Mon Feb 06 01:03:58 CST 2017
     */
    int insertSelective(ByArticle record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_article
     *
     * @mbggenerated Mon Feb 06 01:03:58 CST 2017
     */
    List<ByArticle> selectByExample(ByArticleExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_article
     *
     * @mbggenerated Mon Feb 06 01:03:58 CST 2017
     */
    @Select({
        "select",
        "id, user_id, position_id, article_type, img_url, name, descn, status, create_time, ",
        "update_time, view_count",
        "from by_article",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    ByArticle selectByPrimaryKey(Integer id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_article
     *
     * @mbggenerated Mon Feb 06 01:03:58 CST 2017
     */
    int updateByExampleSelective(@Param("record") ByArticle record, @Param("example") ByArticleExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_article
     *
     * @mbggenerated Mon Feb 06 01:03:58 CST 2017
     */
    int updateByExample(@Param("record") ByArticle record, @Param("example") ByArticleExample example);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_article
     *
     * @mbggenerated Mon Feb 06 01:03:58 CST 2017
     */
    int updateByPrimaryKeySelective(ByArticle record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table by_article
     *
     * @mbggenerated Mon Feb 06 01:03:58 CST 2017
     */
    @Update({
        "update by_article",
        "set user_id = #{userId,jdbcType=INTEGER},",
          "position_id = #{positionId,jdbcType=INTEGER},",
          "article_type = #{articleType,jdbcType=INTEGER},",
          "img_url = #{imgUrl,jdbcType=VARCHAR},",
          "name = #{name,jdbcType=VARCHAR},",
          "descn = #{descn,jdbcType=VARCHAR},",
          "status = #{status,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2TimestampTypeHandler},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP,typeHandler=com.baseweb.mybatis.typehandler.JodaDateTime2TimestampTypeHandler},",
          "view_count = #{viewCount,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(ByArticle record);
}